<?php

namespace App\Admin\Validate;

use App\Common\Validate\Validate;

class SlideValidate extends Validate
{
    public function addGroup($request)
    {
        $method     = $request->getMethod();
        if ($method=='POST'){
            $post       = $request->post();
            $rules      = [
                'name'       => 'required',
                'key'       => 'required',
            ];
            $messages   = [
                'name.required'       => '组名必填',
                'key.required'          => '标识必填',
            ];
            $attributes = [];
            if ($rules) {
                return $this->check($post, $rules, $messages, $attributes);
            }
        }
    }

    public function editGroup($request)
    {
        $method     = $request->getMethod();
        if ($method=='POST'){
            $post       = $request->post();
            $rules      = [
                'id'             => 'required',
                'name'       => 'required',
                'key'       => 'required',
            ];
            $messages   = [
                'id.required'             => '参数丢失',
                'name.required'       => '组名必填',
                'key.required'          => '标识必填',
            ];
            $attributes = [];
            if ($rules) {
                return $this->check($post, $rules, $messages, $attributes);
            }
        }
    }


    public function addSlide($request)
    {
        $method     = $request->getMethod();
        if ($method=='POST'){
            $post       = $request->post();
            $rules      = [
                'icon'             => 'required',
                'slide_group_id'   => 'required',
            ];
            $messages   = [
                'icon.required'            => '图片必填',
                'slide_group_id.required'  => '轮播组必选',
            ];
            $attributes = [];
            if ($rules) {
                return $this->check($post, $rules, $messages, $attributes);
            }
        }
    }

    public function editSlide($request)
    {
        $method     = $request->getMethod();
        if ($method=='POST'){
            $post       = $request->post();
            $rules      = [
                'id'             => 'required',
                'icon'           => 'required',
            ];
            $messages   = [
                'id.required'    => '参数丢失',
                'icon.required'  => '图片必填',
            ];
            $attributes = [];
            if ($rules) {
                return $this->check($post, $rules, $messages, $attributes);
            }
        }
    }


}